/**
  ******************************************************************************
  * @file    bsp_usart.h
  * @author  Iron
  * @date    2018-08-03
  * @version v1.0
  * @brief   bsp usart header file
  */

#ifndef __BSP_USART_H
#define __BSP_USART_H

#ifdef __cplusplus
extern "C" {
#endif

/* includes ------------------------------------------------------------------*/
#include <stdint.h>

/* exported types ------------------------------------------------------------*/
typedef enum
{
    BSP_USART_NULL,  // NOT USED
    BSP_USART1,
    BSP_USART2,
    BSP_USART3,
    BSP_UART4,
    BSP_UART5,
    BSP_USART6,
    BSP_USART_MAX
} bsp_usart_id_t;

typedef void (*usart_isr_rx_indicate_t)(void *handle, uint32_t length);
typedef void (*usart_isr_tx_complete_t)(void *handle);

/* exported constants --------------------------------------------------------*/
/* exported macro ------------------------------------------------------------*/
/* exported functions ------------------------------------------------------- */
int32_t bsp_usart_rx_buf_len(uint32_t uart);
int32_t bsp_usart_rx(uint32_t uart, uint8_t *buf, uint32_t length);

int32_t bsp_usart_dma_tx(uint32_t uart, uint8_t *buf, uint32_t size);
int32_t bsp_usart_poll_tx(uint32_t uart, uint8_t *buf, uint32_t size, uint32_t timeout);
int32_t bsp_usart_putc(uint32_t uart, uint8_t c);

int bsp_usart_init(void *handle, uint32_t uart, uint32_t baudrate, usart_isr_rx_indicate_t rx_indicate, usart_isr_tx_complete_t tx_complete);
int bsp_usart_deinit(uint32_t uart);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __BSP_USART_H */

/******************* (C)COPYRIGHT 2018 ***** END OF FILE *********************/
